package com.lecture.java8.asynchronous;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @program: spring-lecture
 * @description:
 * @author: luyn
 * @create: 2020-04-17 15:46
 **/
public class ExecutorDemo {
    private ExecutorService executorService = Executors.newFixedThreadPool(1);

    public void asynTask() {
        executorService.submit(() -> {
            try {
                Thread.sleep(1000);
            } catch (Exception e) {

            }
            int sum = 0;
            for(int i = 0; i < 1000; i++) {

                sum += i;
            }

            System.out.println(sum);
        });
        //executorService.shutdown();
    }
}
